<%@ page import="org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils" %><g:if test="${legalCaseInstance?.files}">
    <li class="fieldcontain">
        <span id="files-label" class="property-label"><g:message code="legalCase.files.label"
                                                                  default="Files"/></span>

        <g:each in="${legalCaseInstance.files}" var="file">

            <g:if test="${!file.internalFileOnly || SpringSecurityUtils.ifAllGranted('ROLE_ADMIN')}">
                <span class="property-value" aria-labelledby="files-label">

                    <a href="https://s3-eu-west-1.amazonaws.com/casework-files/files/${file.path}">${file?.encodeAsHTML()}</a>

                    <sec:ifAllGranted roles="ROLE_ADMIN">
                        <a href="#" class="close-button" data-name="AttachedFile" data-id="${file.id}">x</a>
                    </sec:ifAllGranted>
                </span>
            </g:if>
        </g:each>

    </li>
</g:if>

<sec:ifAllGranted roles="ROLE_ADMIN">
    <li class="fieldcontain"><span class="property-label"></span>
        <g:if test="${!legalCaseInstance.files}">
            <span id="files-label" class="property-label"><g:message code="legalCase.files.label"
                                                                      default="Files"/></span>
        </g:if>
        <span class="property-value" aria-labelledby="measures-label">
            <g:link action="create" controller="attachedFile" params="[caseId:legalCaseInstance.id]">Attach File</g:link>
        </span>
    </li>
</sec:ifAllGranted>
